package com.zmx.patientend.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.bumptech.glide.Glide;
import com.zmx.patientend.R;
import com.zmx.patientend.pojo.Give;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

public class FriendsLiveAdapter extends BaseAdapter {

    private Context context;
    private List<Give> lists;

    public FriendsLiveAdapter(Context context,List<Give> lists){
        this.context = context;
        this.lists = lists;
    }

    @Override
    public int getCount() {
        return lists.size();
    }

    @Override
    public Object getItem(int position) {
        return lists.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View v, ViewGroup parent) {

        ViewHolder holder = null;
        if(v == null){

            holder = new ViewHolder();
            v = LayoutInflater.from(context).inflate(R.layout.adapter_friends_live,null);
            holder.head = v.findViewById(R.id.head);
            v.setTag(holder);
        }else{

            holder = (ViewHolder) v.getTag();

        }

        Glide.with(context).load(lists.get(position).getAvatar()).into(holder.head);
        return v;
    }

    public class ViewHolder{

        CircleImageView head;

    }

}
